package dom

/**
DOM Load and Save Level 3
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html
*/

/**
Basic Types
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-BasicTypes
*/

type LSInputStream interface{}

type LSOutputStream interface{}

type LSReader interface{}

type LSWriter interface{}

/**
Fundamental Interfaces
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-fundamental
*/

// LSExceptionCode
const (
	PARSE_ERR     = uint16(81)
	SERIALIZE_ERR = uint16(82)
)
/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSException
*/
type LSException struct {
	Code uint16
}

// DOMImplementationLSMode
const (
	MODE_SYNCHRONOUS = uint16(iota + 1)
	MODE_ASYNCHRONOUS
)
/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DOMImplementation
*/
type DOMImplementationLS interface {
	CreateLSParser(mode uint16, schemaType string) (LSParser, DOMException)
	CreateLSSerializer() LSSerializer
	CreateLSInput() LSInput
	CreateLSOutput() LSOutput
}

// ACTION_TYPES
const (
	ACTION_APPEND_AS_CHILDREN = uint16(iota + 1)
	ACTION_REPLACE_CHILDREN
	ACTION_INSERT_BEFORE
	ACTION_INSERT_AFTER
	ACTION_REPLACE
)
/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSParser
*/
type LSParser interface {
	DomConfig() DOMConfiguration
	Filter() LSParserFilter
	SetFilter(LSParserFilter)
	Async() bool
	Busy() bool
	Parse(input LSInput) (Document, DOMException, LSException)
	ParseURI(uri string) (Document, DOMException, LSException)
	ParseWithContext(input LSInput, contextArg Node, action uint16) (Node, DOMException, LSException)
	Abort()
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSInput
*/
type LSInput interface {
	CharacterStream() LSReader
	SetCharacterStream(LSReader)
	ByteStream() LSReader
	SetByteStream(LSReader)
	StringData() string
	SetStringData(string)
	SystemId() string
	SetSystemId(string)
	PublicId() string
	SetPublicId(string)
	BaseURI() string
	SetBaseURI(string)
	Encoding() string
	SetEncoding(string)
	CertifiedText() bool
	SetCertifiedText(bool)
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSResourceResolver
*/
type LSResourceResolver interface {
	ResolveResource(typp, namespaceURI, publicId, systemId, baseURI string) LSInput
}

// Constants returned by startElement and acceptNode
const (
	FILTER_ACCEPT = int16(iota + 1)
	FILTER_REJECT
	FILTER_SKIP
	FILTER_INTERRUPT
)
/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSParserFilter
*/
type LSParserFilter interface {
	StartElement(elementArg Element) uint16
	AcceptNode(nodeArg Node) uint16
	WhatToShow() uint64
	SetWhatToShow(uint64)
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSProgressEvent
*/
type LSProcessEvent interface {
	Input() LSInput
	Position() uint64
	TotalSize() uint64
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSLoadEvent
*/
type LSLoadEvent interface {
	NewDocument() Document
	Input() LSInput
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSSerializer
*/
type LSSerializer interface {
	DomConfig() DOMConfiguration
	NewLine() string
	SetNewLine(string)
	Filter() LSSerializerFilter
	SetFilter(LSSerializerFilter)
	Write(nodeArg Node, destination LSOutput) (bool, LSException)
	WriteToURI(nodeArg Node, uri string) (bool, LSException)
	WriteToString(nodeArg Node) (string, DOMException, LSException)
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSOutput
*/
type LSOutput interface {
	CharacterStream() LSWriter
	SetCharacterStream(LSWriter)
	ByteStream() LSOutputStream
	SetByteStream(LSOutputStream)
	SystemId() string
	SetSystemId(string)
	Encoding() string
	SetEncoding(string)
}

/*
see http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSSerializerFilter
*/
type LSSerializerFilter interface {
	WhatToShow() uint64
}
